
// 函数节流
export const throttle = function(fn, gapTime) {
	let _lastTime = null;
	return function() {
		let _nowTime = +new Date()
		if (_nowTime - _lastTime > gapTime || !_lastTime) {
			fn(arguments);
			_lastTime = _nowTime
		}
	}
}

//获取节点尺寸
export const getNodeClientRect = (select, ctx, inThis = true) => {
    let res = null;
    if (inThis) {
        res = uni.createSelectorQuery().in(ctx);
    } else {
        res = uni.createSelectorQuery();
    }
    res.selectAll(select).boundingClientRect();
    return new Promise((resolve, reject) => {
        res.exec(data => {
            if (data && data != '' && data != undefined && data.length) {
                resolve(data);
            } else {
                resolve(false);
            }
        });
    });
}
